package cn.bonoon.kernel.menus;

import java.util.Properties;

import cn.bonoon.kernel.util.StringHelper;

public class VersionInfo {
	
	private final String version;
	private final String name;
	private String image;
	private String company;
	private String time;
	private String team;
	private String des;
	private String phone;
	
	VersionInfo(String cpath, Properties p){
		version = p.getProperty("about.version");
		name = p.getProperty("about.name");
		image = p.getProperty("about.image");
		if(StringHelper.isEmpty(image)){
			image = cpath + "/res/images/unknow-plugin.png";
		}else{
			image = cpath + image;
		}
		company = p.getProperty("about.company");
		time = p.getProperty("about.time");
		team = p.getProperty("about.team");
		des = p.getProperty("about.des");
		phone = p.getProperty("about.phone");
	}
	public void parse(String id, int i, StringBuilder thums, StringBuilder des){
		thums.append("<a style='padding:4px;border-style:none;border-width:0px;border-bottom-width:0px;' title='").append(name);
		thums.append("' href='#' id='thum-").append(id).append('-').append(i);
		thums.append("'><img height='32' src='").append(image).append("'/></a>");
		
		des.append("<table id='des-thum-").append(id).append('-').append(i);
		des.append("' style='width:100%;display:none;' border='0' cellpadding='0' cellspacing='0'>");
		des.append("<tr><td rowspan='5' align='center' valign='top' style='width:80px;'><img src='").append(image);
		des.append("' height='64'/></td><td align='right' style='width:60px;'><b>版本：</b></td><td>").append(version);
		des.append("</td></tr><tr><td align='right'><b>名称：</b></td><td>").append(name).append("</td></tr>");
		if(StringHelper.isNotEmpty(company)){
			des.append("<tr><td align='right'><b>公司：</b></td><td>").append(company);
			if(StringHelper.isNotEmpty(phone)){
				des.append("(联系电话：").append(phone).append(')');
			}
			des.append("</td></tr>");
		}
		if(StringHelper.isNotEmpty(team)){
			des.append("<tr><td align='right'><b>团队：</b></td><td>").append(team);
			if(StringHelper.isNotEmpty(time)){
				des.append("(时间：").append(time).append(')');
			}
			des.append("</td></tr>");
		}
		if(StringHelper.isNotEmpty(this.des)){
			des.append("<tr><td align='right'><b>说明：</b></td><td>").append(this.des).append("</td></tr>");
		}
		des.append("</table>");
	}

}
